package com.geping.etl.common.service.impl;

import com.geping.etl.common.entity.Sys_Cmdtask_Param;
import com.geping.etl.common.repository.Sys_Cmdtask_ParamRepository;
import com.geping.etl.common.service.Sys_Cmdtask_ParamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Iterator;
import java.util.Objects;

/**
 * @Author pengcheng.peng
 * @Date 2021/7/30 14:59
 * @Version 1.0
 */
@Service
public class Sys_Cmdtask_ParamServiceImpl implements Sys_Cmdtask_ParamService {

    @Autowired
    private Sys_Cmdtask_ParamRepository cmdtask_paramRepository;


    @Transactional
    @Override
    public void refreshDataDate(String dataDate) {
        Sys_Cmdtask_Param sys_Cmdtask_Param=null;
        Iterator iterator=cmdtask_paramRepository.findAll().iterator();
        if(iterator.hasNext()){
            sys_Cmdtask_Param= (Sys_Cmdtask_Param) iterator.next();
        }
        if(Objects.isNull(sys_Cmdtask_Param)){
            sys_Cmdtask_Param=new Sys_Cmdtask_Param();
        }
        sys_Cmdtask_Param.setData_date(dataDate);
        cmdtask_paramRepository.save(sys_Cmdtask_Param);
    }
}
